package cn.bugstack.springframework.mydemo;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class MyBeanFactory {
    Map<String,MyBeanDefinition> myBeanDefinitions = new ConcurrentHashMap<>();

    public void registerBeanDefinition(String name, MyBeanDefinition beanDefinition) {
        myBeanDefinitions.put(name,beanDefinition);
    }

    public Object getBean(String name) throws InstantiationException, IllegalAccessException {
        MyBeanDefinition beanDefinition = myBeanDefinitions.get(name);
        return beanDefinition.getBean();
    }
}
